<?php
$masterView = MasterView::getInstance();
$folder = Folder::withId($masterView->streamView->model->folderId);
$folderType = $folder->folderType;
$twitter = Twitter::getTwitters();
$facebook = Facebook::getFacebooks();
$google = Google::getGoogles();
$linkedin = LinkedIn::getLinkedIns();
$filter = '';
$completeText = '';
if (isset($_REQUEST['filter']))
    $filter = $_REQUEST['filter'];
if (!is_array($masterView->streamView->signals))
    return;
for ($i = 0; $i < count($masterView->streamView->signals); $i++) :
    $item = $masterView->streamView->signals[$i];
    $messageTags = $item->findTag();
    $messageId = $item->message->getId();
    $streamId = $masterView->streamView->model->streamId;
    $threadId = $item->message->getThreadId();
    $domain = parse_url($item->message->getURL(), PHP_URL_HOST);
    $messageActionData = MessageAction::getByMessageId($threadId, $streamId);

    if (!$filter) {
        if ($messageActionData[2] || $messageActionData[3] || $messageActionData[4])
            continue;
    }
    else {
        $continue = 0;
        if (strpos($filter, '/')) {
            $filters = explode('/', $filter);
            $filter = $filters[0];
        }
        switch ($filter) {
            case 'favorite':
                if (isset($messageActionData[2]) || isset($messageActionData[3]) || isset($messageActionData[4])) {
                    $continue = 1;
                }
                break;
            case 'archive':
                if ($messageActionData[3] || $messageActionData[4])
                    $continue = 1;
                break;
            case 'spam':
                if ($messageActionData[2] || $messageActionData[4])
                    $continue = 1;
                break;
            case 'trash':
                break;
        }
        if ($continue)
            continue;
    }

    if ($messageId < 10) {
        $messageId = $item->messageID;
    }
    $mentionStyle = '';
    $fbUserId = '';
    $postId = '';
    if ($domain == 'www.facebook.com') {
        $postParams = explode('/', $item->message->getURL());
        $postData = $postParams[5];
        $data = explode('?comment_id=', $postData);
        $fbUserId = $postParams[3];
        $postId = $data[0];
        $mentionStyle .= 'padding-left: 85px';
    }
    $videoId = '';
    if ($item->message->getSource() == 'www.youtube.com') { //Parse youtube links
        $url = $item->message->getURL();
        $urlParams = explode('?v=', $url);
        $videoIdTemp = $urlParams[1];
        $idParams = explode('&', $videoIdTemp);
        $videoId = $idParams[0];
        $embedUrl = "https://youtube.googleapis.com/v/" . $videoId;
    }
    if ($item->image != '') {
        $mentionStyle .= 'padding-right: 105px';
    }
    if (count($item->leadData['replies']) > 0)
        $item->date = $item->leadData['replies'][0]['time'];
    $timestamp = $item->date->format("U");

    $smsTitle = substr($item->message->getThreadTitle(), 0, 50);
    $smsSource = str_replace('www.', '', $item->message->getSource());
    $smsDate = $item->date->format('d/m/Y');
    $smsTime = $item->date->format('h:i A');
    $smsURL = $item->message->getURL();
    $smsContent = "[BUZZMETRICS ALERT] Message triggers alarm: '$smsTitle' on $smsSource, $smsDate, $smsTime\r\n$smsURL";
    $shortText = '';
    ?><li class="mozaic-widget list-item story-signal mozaic-initialized widget-story_signal <?php echo ($item->message->isRead != 0) ? "" : "unread" ?>" messageid="<?php echo $messageId; ?>" threadid="<?php echo $threadId; ?>" streamid="<?php echo $streamId; ?>">
        <div class="mention-container alert-container alert-story-container signal-green">
            <div class="mention-left-content">
                <div class="annotable-extra-container">
                    <div class="mozaic-widget mozaic-initialized widget-signal_annotable_extra">
                        <p class="mention-time-stamp extend signals-time-stamp-3" data-timestamp="<?php echo $timestamp; ?>">
                            <?php
                            echo Utils::humanTiming($item->date->format("U"));
                            ?>
                        </p>

                        <p class="mention-type additional-timestamp" data-timestamp="<?php echo $timestamp; ?>"><?php echo $item->date->format("M d Y h:m A"); ?></p>
                    </div>
                </div>
                <div class="mention-circle-holder <?php echo StreamController::getSMTIcon($item->type); ?>">
                    <i class="icon-cirlce-background"></i>
                    <div class="icon-circle-mention background-twitter ">
                        <i class="icon-mention-<?php echo StreamController::getSMTIcon($item->type); ?> responsive-l1"></i>
                    </div>
                </div>
            </div>

            <div class="mention-right-content">
                <div class="mention-right-wrapper">
                    <div class="mention-right-container extend">
                        <div class="mention-content blog_mention">
                            <div class="mention-core">
                                <div class="mention-core-wrapper">
                                    <div class="mention-content-full">
                                        <p class="mention-type additional-timestamp signals-additional-time" data-timestamp="<?php echo $timestamp; ?>" style="float: right;"><?php echo $item->date->format("M d Y h:m A"); ?></p>
                                        <div class="resource-text-container" >
                                            <p class="mention-title" text='<a class="action-color-hover" href="<?php echo $item->message->getURL(); ?>" target="_blank"><?php echo $item->message->getThreadTitle(); ?></a>'><a class="action-color-hover" href="<?php echo $item->message->getURL(); ?>" target="_blank"><?php echo $item->message->getThreadTitle(); ?></a></p>
                                            <?php
                                            $parse = parse_url($item->message->getURL());
                                            $parsedSource = str_ireplace('www.', '', $parse["host"]);
                                            ?>
                                            <p class="mention-short-url"><img style="width:16px;margin-right:5px;" src="http://www.google.com/s2/favicons?domain=<?php echo $domain; ?>" /><a class="action-color-active" source="<?php echo $item->message->getSource(); ?>" href="<?php echo $item->message->getURL(); ?>" text="<?php echo $parsedSource; ?>" target="_blank"><?php
                                                    echo $parsedSource;
                                                    ?></a><a style="margin-left: 5px; padding-left: 5px; border-left: 1px solid orange;" class="action-color-active"  text="<?php echo $item->message->getLeadAuthor(); ?>" target="_blank"><?php
                                                    echo $item->message->getLeadAuthor();
                                                    ?></a><a class="toggle-link" style="margin-left: 5px; padding-left: 5px; border-left: 1px solid orange;" class="action-color-active">show links</a></p>
                                            <div class="thread-details">
                                                <div class="numberOfReplies">
                                                    <i class="icon-mention-replies"></i>
                                                    <div><?php echo $item->totalReplies ?></div>
                                                    <div class="newReplies">1</div>
                                                </div>
                                                <div class="numberOfLikes">
                                                    <i class="icon-mention-likes"></i>
                                                    <div><?php echo $item->message->getNumberOfLikes() ?></div>
                                                </div>
                                            </div>
                                        </div>
                                        <?php if ($domain == 'www.facebook.com') { ?>
                                            <div class="profile-img" style="width: 80px; height: 80px; overflow:hidden; padding-top: 5px; padding-right: 10px;float:left;">
                                                <img src="http://graph.facebook.com/<?php echo $fbUserId; ?>/picture?type=large" width="100%"/>
                                            </div>
                                        <?php } ?>
                                        <div class="mention-text" style="<?php echo $mentionStyle; ?>">
                                            <?php
                                            $text = trim(rtrim($item->lead, 'null'));
                                            $text = str_replace('(javascript:void(0))', '', $text);
                                            $text = str_replace("\n", "<br>", $text);
                                            eregi("<blockquote>(.*)</blockquote>", $text, $data);
                                            $blockQuote = '';
                                            if (count($data))
                                                $blockQuote = $data[0];
                                            $text = str_replace($blockQuote, "{blockquote}", $text);
                                            $threadId = $item->message->getThreadId();
                                            $data = Sentiment::saveSentiment(Signal::removeLink($text), $masterView->streamView->model->streamId, $messageId, $threadId, $item->message->getTime(), $item->type, $item->message->getSource());
                                            $sentimentScore = $data["score"];
                                            $sentimentText = $data["text"];
                                            $sentimentColor = $data["color"];
                                            if (substr_count($text, " ") > 100) {
                                                //find the 100th char(' ')
                                                $endpos = 200;
                                                $endpos = strpos($text, " ", $endpos);
                                                $shortText = substr($text, 0, $endpos);
                                                echo str_replace("{blockquote}", $blockQuote, $shortText);
                                                ?>
                                                <span class="readmore-threedot">...</span>
                                                <span class="readmore spanshow" onclick="expand(this);" style="color: orange; cursor: pointer; white-space: nowrap;">Read more</span>
                                                <span class="readmore-content hide"><?php echo str_replace("{blockquote}", $blockQuote, substr($text, $endpos)); ?></span>
                                                <span class="readmore spanshow hide" onclick="unexpand(this);" style="color: orange; cursor: pointer; white-space: nowrap;">Show less</span>
                                                <?php
                                            } else
                                                echo str_replace("{blockquote}", $blockQuote, $text);
                                            ?>
                                            <?php if ($videoId) : ?>
                                                <div class="video-thumb-container" id="imagecontainer-<?php echo $videoId; ?>">
                                                    <div class="thumbnail-overlay play-video" data-video-id="<?php echo $videoId; ?>">
                                                        <i class="icon-play play-video"></i>
                                                    </div>
                                                    <img class="video-thumnail" src="http://img.youtube.com/vi/<?php echo $videoId; ?>/0.jpg">
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                                <div class="tags-holder-container first-two-tags">
                                    <div class="mozaic-widget mozaic-initialized widget-annotable_tags">
                                        <div class="clear"></div>
                                    </div>
                                </div>
                                <div class="more-tags-holder">
                                    <span>...</span>
                                    <div class="more-tags-tooltip">
                                        <div class="arrow-icon"></div>
                                        <div class="tags-holder-container more-tags-container">
                                            <div class="mozaic-widget mozaic-initialized widget-annotable_tags">
                                                <div class="clear"></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="signal-action-bar-container"><div class="mozaic-widget widget-signal_action_bar" data-widget="signal_action_bar" >
                                        <div class="signal-review-bar"><p><font><font>Reach Out</font></font></p></div>
                                        <ul class="mention-action-bar">
                                            <?php
                                            if ($twitter['accountid'] != 'undefined' || $facebook['accountid'] != 'undefined' || $google['accountid'] != 'undefined' || $linkedin['accountid'] != 'undefined') {
                                                $liStyle = 'display: block';
                                            } else {
                                                $liStyle = 'display: none';
                                            }
                                            ?>
                                            <li class="mention-action-button retweet_dropdown" style="<?php echo $liStyle; ?>" messageId="<?php echo $item->messageID; ?>" streamId="<?php echo $item->streamID; ?>" threadId="<?php echo $threadId; ?>">
                                                <div class="btn-group dropdown">
                                                    <button href="#" class="btn btn-danger retweet action-color-background dropdown-toggle" data-toggle="dropdown" data-platform-id="377747108537061378">
                                                        <i class="icon-action-retweet"></i><div>Share</div><i class="icon-action-dropdown"></i>
                                                    </button>
                                                    <div class="tag-mention">
                                                        <span class="square-hack"></span>
                                                        <div class="dropdown-menu">
                                                            <ul class="overview">
                                                                <?php if ($twitter['accountid'] != 'undefined') : ?>
                                                                    <li data-id="902">
                                                                        <a class="retweet_this" data-action="retweet" data-platform-id="377747108537061378"><i class="icon-circle-list"></i>Twitter</a>
                                                                    </li>
                                                                <?php endif; ?>
                                                                <?php if ($facebook['accountid'] != 'undefined') : ?>
                                                                    <li data-id="903">
                                                                        <a class="retweet_this" data-action="facebook" data-platform-id="377747108537061378"><i class="icon-circle-list"></i>Facebook</a>
                                                                    </li>
                                                                <?php endif; ?>
                                                                <?php if ($google['accountid'] != 'undefined') : ?>
                                                                    <li data-id="902">
                                                                        <a id="myBtn" class="retweet_this demo g-interactivepost" 
                                                                           data-clientid="208044150507.apps.googleusercontent.com"
                                                                           data-contenturl="<?php echo $item->message->getURL(); ?>"
                                                                           data-calltoactionlabel="INVITE"
                                                                           data-calltoactionurl="https://developers.google.com/+/web/share/interactive?invite=true"
                                                                           data-cookiepolicy="single_host_origin"
                                                                           data-prefilltext="<?php echo strip_tags(str_replace("<br>", "\n", substr($text, 0, $endpos))) . '...'; ?>"><i class="icon-circle-list"></i>Google+</a>
                                                                    </li>
                                                                <?php endif; ?>
                                                                <?php if ($linkedin['accountid'] != 'undefined') : ?>
                                                                    <li data-id="903">
                                                                        <a class="retweet_this" data-action="linkedin" data-platform-id="377747108537061378"><i class="icon-circle-list"></i>LinkedIn</a>
                                                                    </li>
                                                                <?php endif; ?>
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                            <?php if ($domain == 'www.facebook.com' && $facebook['accountid'] != 'undefined') : ?>
                                                <li class="mention-action-button">
                                                    <button class="btn btn-danger reply" fbpostid="<?php echo $fbUserId . '_' . $postId; ?>"><i class="icon-action-reply"></i>Reply</button>
                                                </li>
                                            <?php endif; ?>
                                            <li class="mention-action-button mention-actions mention-tag">
                                                <div class="btn-group">
                                                    <button data-toggle="dropdown" class="btn btn-danger"><i class="icon-action-tag"></i><div><font>Tag</font></div><i class="icon-action-dropdown"></i></button>
                                                </div>
                                            </li>
                                            <li class="mention-action-button">
                                                <button class="btn btn-danger add-task" messageId="<?php echo $messageId; ?>" post="<?php echo substr(htmlspecialchars(str_replace('<br>', '', Signal::removeLink($text))), 0, 300) . '...'; ?>" streamId="<?php echo $masterView->streamView->model->streamId; ?>"><i class="icon-action-addtask"></i><em></em><div><em><font><font>Add&nbsp;</font></font></em><font><font>task</font></font></div></button>
                                            </li>             
                                            <li class="mention-action-button mention-actions mention-favorite">
                                                <button class="btn btn-danger message-action first">
                                                    <i class="icon-action-favorite <?php if ($messageActionData[1]) echo 'icon-active' ?>"></i>
                                                </button> 
                                                <div class="left-menu-tooltip fade bottom in" <?php if ($messageActionData[1]) echo 'style="margin-left: -50px;"' ?>>
                                                    <div class="tooltip-arrow"></div>
                                                    <div class="tooltip-inner"><?php echo ($messageActionData[1]) ? 'Remove from Favorite' : 'Add to Favorite' ?></div>
                                                </div>
                                            </li>
                                            <li class="mention-action-button mention-actions mention-archive">
                                                <button class="btn btn-danger message-action"><i class="icon-action-archive <?php if ($messageActionData[2]) echo 'icon-active' ?>"></i></button> 
                                                <div class="left-menu-tooltip fade bottom in" <?php if ($messageActionData[2]) echo 'style="margin-left: -65px;"' ?>>
                                                    <div class="tooltip-arrow"></div>
                                                    <div class="tooltip-inner"><?php echo ($messageActionData[2]) ? 'Unarchive this message' : 'Archive this message' ?></div>
                                                </div>
                                            </li>
                                            <li class="mention-action-button mention-actions mention-trash">
                                                <button class="btn btn-danger message-action"><i class="icon-action-trash <?php if ($messageActionData[4]) echo 'icon-active' ?>"></i></button> 
                                                <div class="left-menu-tooltip fade bottom in" style="margin-left: <?php echo $messageActionData[4] ? '-54px' : '-42px' ?>;">
                                                    <div class="tooltip-arrow"></div>
                                                    <div class="tooltip-inner"><?php echo $messageActionData[4] ? 'Remove from Trash' : 'Move to Trash' ?></div>
                                                </div>
                                            </li>
                                            <li class="mention-action-button mention-actions mention-spam">
                                                <div class="btn-group message-action">
                                                    <button data-toggle="dropdown" class="btn btn-danger <?php if ($filter == 'spam') echo 'remove-spam' ?>"><i class="icon-action-spam <?php if ($filter == 'spam') echo 'icon-active' ?>"></i><?php if ($filter != 'spam') echo '<i class="icon-action-dropdown"></i>'; ?></button>
                                                    <div class="left-menu-tooltip fade bottom in" style="margin-left: <?php echo ($filter == 'spam') ? '-52px' : '-35px' ?>">
                                                        <div class="tooltip-arrow"></div>
                                                        <div class="tooltip-inner"><?php echo ($filter == 'spam') ? 'Remove from Spam' : 'Mark as Spam' ?></div>
                                                    </div>
                                                    <?php if ($filter != 'spam') : ?>
                                                        <div class="mozaic-widget tag_mention widget-spam">
                                                            <span class="square-hack"></span>
                                                            <div class="dropdown-menu">
                                                                <ul class="overview" messageid="<?php echo $messageId ?>" threadid="<?php echo $threadId; ?>" streamId="<?php echo $masterView->streamView->model->streamId; ?>">
                                                                    <li><a class="spam-link-author"><i class="icon-circle-list"></i>Exclude all future messages from this Author</a></li>
                                                                    <li><a class="spam-link-source"><i class="icon-circle-list"></i>Exclude all future messages from this Source</a></li>
                                                                </ul>
                                                            </div>
                                                        </div>
                                                    <?php endif; ?>
                                                </div>       
                                            </li>
                                            <div class="tasks-holder-container">
                                                <?php
                                                $tasks = $item->findTask();
                                                $taskText = array();
                                                if (count($tasks) > 0) {
                                                    echo count($tasks) . ' tasks assigned';
                                                    foreach ($tasks as $task) {
                                                        $user1 = User::withId($task->taskUserId);
                                                        $user2 = User::withId($task->taskAssignedTo);
                                                        $taskText[] = $user1->name . ' assigned a task to ' . $user2->name;
                                                    }
                                                }
                                                ?>
                                                <div class="left-menu-tooltip fade bottom in" <?php if ($messageActionData[2]) echo 'style="margin-left: -65px;"' ?>>
                                                    <div class="tooltip-arrow"></div>
                                                    <div class="tooltip-inner"><?php echo implode('<br>', $taskText); ?></div>
                                                </div>
                                            </div>
                                            <div class="tags-holder-container">
                                                <?php
                                                foreach ($item->findTag() as $tag) {
                                                    echo '<div class="tag-holder-container"><label>' . $tag->tagName . '</label><a class="remove-tag">x</a></div>';
                                                }
                                                ?>
                                            </div>
                                        </ul>
                                    </div>
                                </div>
                                <div class="mention-right-action-bar">

                                    <ul class="nav nav-list right-action-bar" date="<?php echo $item->date->format("M d Y h:m A"); ?>" messageId="<?php echo $item->message->getId(); ?>" threadId="<?php echo $item->message->getThreadId(); ?>" type="<?php echo $item->message->getType() ?>" source="<?php echo $item->message->getSource() ?>">

                                        <li class="right-action-item language-action-tab ">
                                            <div class="language">
                                                <a class="set-filter cursor-pointer" rel="tooltip" title="Show all English mentions">
                                                    <i class="icon-language-indicator"></i><span class="text-to-hide">vietnamese</span>
                                                </a>

                                            </div>
                                        </li>
                                        <li class="right-action-item sentiment-item-list">
                                            <div class="sentiment">
                                                <a class="set-filter positive cursor-pointer" rel="tooltip" title="Show all positive mentions" style="background-color: <?php echo $sentimentColor; ?>;">
                                                    <i class="icon-<?php echo $sentimentText; ?>" style="background-color: <?php echo $sentimentColor; ?>;"></i><span class="text-to-hide"><?php echo $sentimentText; ?></span>
                                                </a>
                                            </div>
                                            <div class="btn-group">
                                                <button class="btn btn-small dropdown-toggle" style="width: 25px;"><i class="icon-right-dropdown"></i></button>
                                            </div>
                                        </li>

                                        <li class="right-action-item send-action-tab">
                                            <div class="send">
                                                <a class="cursor-pointer send-menu <?php if (bpServer::isMarkForSendingLater($streamId, $messageId)) echo "marked" ?>" messageId="<?php echo $messageId; ?>" streamid="<?php echo $streamId; ?>" threadtitle="[BUZZMETRICS ALERT] <?php echo $item->message->getThreadTitle() ?>" content="<?php echo $smsContent; ?>" threadid="<?php echo $item->message->getThreadId(); ?>" >
                                                    <i class="icon-share-indicator"></i><span class="text-to-hide">Send</span>
                                                </a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="annotables-replies-content thread-replies">
                        <div class="annotations-holder-container">
                            <div class="mozaic-widget mozaic-initialized widget-annotable_tasks_and_posts">
                                <div class="tasks-and-posts">
                                    <div class="annotable-tasks-and-posts">
                                        <div class="mozaic-widget task-14349 first_overall last_overall first last" data-guid="widget-219" data-initialized="true">

                                            <div class="mention-container stream-task-container <?php echo $completeText ?>">
                                                <div class="mention-right-content">
                                                    <div class="mention-right-wrapper">
                                                        <div class="mention-right-container">
                                                            <div class="mention-content">
                                                                <?php
                                                                if ($item->leadData["replies"])
                                                                    if (count($item->leadData["replies"])) :
                                                                        $count = 0;
                                                                        foreach ($item->leadData["replies"] as $reply):
                                                                            $count++;
                                                                            $author = $reply['author'];
                                                                            $replyText = Signal::removeLink($reply['text']);
                                                                            if ($author == '')
                                                                                $author = 'Someone';
                                                                            ?>
                                                                            <div class="user-author-mention-actions mention-top-bar <?php if ($count > 5) echo 'hide'; ?>" style="height: auto;">
                                                                                <div class="float-left user-image">
                                                                                    <?php if ($domain == 'www.facebook.com') : ?>
                                                                                        <img class="<?php echo $reply['fbObjectId'] . '_' . $reply['fbCommentId']; ?>" style="width: 32px; height: 32px; border-radius: 0;" postid="<?php echo $fbPostId; ?>" commentid="<?php echo $fbCommentId; ?>" src="Images/avatar.png"/>
                                                                                        <!--<script>
                                                                                    $.get('/fbimage/<?php echo $reply['fbObjectId'] . '/' . $reply['fbCommentId']; ?>', function(data) { $('.<?php echo $reply['fbObjectId'] . '_' . $reply['fbCommentId']; ?>').attr('src', 'http://graph.facebook.com/'+data+'/picture?type=small'); })
                                                                                </script>-->
                                                                                        <?php
                                                                                    else :
                                                                                        ?>
                                                                                        <img style="width: 32px; height: 32px; border-radius: 0;" src="Images/avatar.png"/>
                                                                                    <?php
                                                                                    endif;
                                                                                    ?>
                                                                                </div>
                                                                                <div class="float-left main-reply-content">
                                                                                    <p style="overflow: hidden; display: block;"><strong><a class="parsed-link" href="<?php echo $reply['authorUrl'] ?>"><?php echo $author ?></a>: </strong><?php
                                                                                        $replyText = rtrim($replyText, '<br');
                                                                                        $replyText = trim($replyText, 'quote<br><br>');
                                                                                        $threadId = $item->message->getThreadId();
                                                                                        $data = Sentiment::saveSentiment($replyText, $masterView->streamView->model->streamId, $reply['messageId'], $threadId, $item->message->getTime(), $item->type, $item->message->getSource);
                                                                                        $sentimentScore = $data["score"];
                                                                                        $sentimentText = $data["text"];
                                                                                        $sentimentColor = $data["color"];
                                                                                        if (strlen($replyText) > 150) {
                                                                                            $endpos = 150;
                                                                                            $endpos = strpos($replyText, " ", $endpos);
                                                                                            if (!$endpos) {
                                                                                                $endpos = strlen($replyText);
                                                                                                ?><span><?php
                                                                                                            echo $replyText;
                                                                                                            ?></span>
                                                                                                <?php
                                                                                            } else {
                                                                                                ?><span><?php
                                                                                                        echo substr($replyText, 0, $endpos);
                                                                                                        ?></span>
                                                                                                <span class="readmore-threedot">...</span>
                                                                                                <span class="readmore spanshow" onclick="expand(this);" style="color: orange; cursor: pointer; white-space: nowrap;">Read more</span>
                                                                                                <span class="readmore-content hide"><?php echo substr($replyText, $endpos); ?></span>
                                                                                                <span class="readmore spanshow hide" onclick="unexpand(this);" style="color: orange; cursor: pointer; white-space: nowrap;">Show less</span>
                                                                                                <?php
                                                                                            }
                                                                                        } else
                                                                                            echo '<span>' . $replyText . '</span>';
                                                                                        ?>
                                                                                    </p>
                                                                                </div>

                                                                                <div class="float-right">
                                                                                    <span class="task-posted-time" style="line-height: 22px"><?php echo $reply['time']->format("M d Y h:m A"); ?></span>
                                                                                </div>
                                                                                <div class="thread-details">
                                                                                    <div class="numberOfLikes">
                                                                                        <i class="icon-mention-likes"></i>
                                                                                        <div><?php echo $item->message->getNumberOfLikes() ?></div>
                                                                                    </div>
                                                                                </div>
                                                                                <div class="mention-right-action-bar" style="top: inherit;">
                                                                                    <ul class="nav nav-list right-action-bar" date="<?php echo $item->date->format("M d Y h:m A"); ?>" messageId="<?php echo $reply["messageId"]; ?>" threadId="<?php echo $reply["threadId"]; ?>">
                                                                                        <li class="right-action-item sentiment-item-list">
                                                                                            <div class="sentiment">
                                                                                                <a class="set-filter positive cursor-pointer" rel="tooltip" title="Show all positive mentions" style="background-color: <?php echo $sentimentColor; ?>;">
                                                                                                    <i class="icon-<?php echo $sentimentText; ?>" style="background-color: <?php echo $sentimentColor; ?>;"></i><span class="text-to-hide"><?php echo $sentimentText; ?></span>
                                                                                                </a>
                                                                                            </div>
                                                                                            <div class="btn-group">
                                                                                                <button class="btn btn-small dropdown-toggle" style="width: 25px;"><i class="icon-right-dropdown"></i></button>
                                                                                            </div>
                                                                                        </li>
                                                                                    </ul>
                                                                                </div>
                                                                            </div>
                                                                            <?php
                                                                        endforeach;
                                                                        ?><?php if ($item->totalReplies != count($item->leadData['replies']) && $item->totalReplies > 5): ?>
                                                                            <div class="loadMoreReply">
                                                                                <a>Load more replies</a>
                                                                                <div class="background-loading-small hide">
                                                                                    <div class="duo duo1">
                                                                                        <div class="dot dot-a"></div>
                                                                                        <div class="dot dot-b"></div>
                                                                                    </div>
                                                                                    <div class="duo duo2">
                                                                                        <div class="dot dot-a"></div>
                                                                                        <div class="dot dot-b"></div>
                                                                                    </div>
                                                                                </div> 
                                                                            </div>
                                                                        <?php endif; ?>
                                                                        <?php
                                                                    
                                                                endif;
                                                                ?>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="clear"></div>
            </div>
        </div>
    </li>
<?php endfor; ?>